--侦探守则
local zhentanshouze = fk.CreateSkill {
    name = "mcdh_zhentanshouze",
    tags = {Skill.Compulsory}
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

zhentanshouze:addEffect(fk.TurnEnd,{
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(self) and player:canUse(Fk:cloneCard("slash"), {bypass_times=true}) then
            local room = player.room
            local events = room.logic:getEventsOfScope(GameEvent.Death, 999, function(e)
                local deathStruct = e.data[1]
                return deathStruct.damage and deathStruct.damage.from and deathStruct.damage.from ~= player and player:canUseTo(Fk:cloneCard("slash"),deathStruct.damage.from,{bypass_distances = true,bypass_times=true})
            end, Player.HistoryTurn)
            return #events > 0
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local can_choose = {}
        local events = room.logic:getEventsOfScope(GameEvent.Death, 999, function(e)
            local deathStruct = e.data[1]
            if deathStruct.damage and deathStruct.damage.from and deathStruct.damage.from ~= player and player:canUseTo(Fk:cloneCard("slash"),deathStruct.damage.from,{bypass_distances = true,bypass_times=true}) then
                table.insertIfNeed(can_choose,deathStruct.damage.from.id)
            end
            return false
        end, Player.HistoryTurn)
        U.askForUseVirtualCard(room,player,"slash",nil,self.name,"#mcdh_zhentanshouze_askfor",false,true,true,true,{exclusive_targets = can_choose})
    end
})

Fk:loadTranslationTable{
    ["mcdh_zhentanshouze"] = "守则",
    [":mcdh_zhentanshouze"] = "『侦探守则』<br>锁定技，每个回合结束时，你视为对本回合杀死过角色的一名其他角色使用一张无距离次数限制的【杀】。",
    ["#mcdh_zhentanwanzun_chooseplayer"] = "侦探挽尊：你可以猜测其中一名目标角色的手牌中有无哪些花色的牌，根据猜对数量执行效果",
    ["#mcdh_zhentanwanzun_choosesuit"] = "侦探挽尊：选择你认为目标手牌中存在哪些花色，未选择花色则为你认为目标手牌中不存在该种花色",
    ["#mcdh_zhentanwanzun_log"] = "%to 猜对了 %arg 项",
    ["#mcdh_zhentanshouze_askfor"] = "侦探守则：请视为对本回合杀死过角色的其他角色使用一张【杀】"
}
return zhentanshouze